//
//  PdfVipController.m
//  PdfChange
//
//  Created by 蓝鳍互娱 on 2024/7/26.
//

#import "PdfVipController.h"

@interface PdfVipController ()
@property (nonatomic,strong) UILabel *pdfVipPriceLab;
@property (nonatomic,strong) UILabel *pdfVipAlertLab;
@end
@implementation PdfVipController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatPdfSubView];
}
- (void)creatPdfSubView{
    UIImageView * pdfVipBgImgView = [[UIImageView alloc] init];
    pdfVipBgImgView.image = PdfImageNamed(@"pdfVipBg");
    pdfVipBgImgView.userInteractionEnabled = true;
    [self.view addSubview:pdfVipBgImgView];
    [pdfVipBgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(PdfRatio(0)));
    }];
    UIButton * pdfVipBackBtn = [[UIButton alloc] init];
    [pdfVipBackBtn setBackgroundImage:PdfImageNamed(@"pdfVipBack") forState:UIControlStateNormal];
    [pdfVipBackBtn addTarget:self action:@selector(pdfVipBack) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pdfVipBackBtn];
    [pdfVipBackBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(24)));
        make.top.equalTo(@(PdfRatio(22) + PdfTopSafeHeight));
        make.width.equalTo(@(PdfRatio(64)));
        make.height.equalTo(@(PdfRatio(64)));
    }];
    self.pdfVipPriceLab = [[UILabel alloc] init];
    self.pdfVipPriceLab.numberOfLines = 0;
    self.pdfVipPriceLab.textColor = PdfHex(@"#16133E");
    self.pdfVipPriceLab.font = [UIFont systemFontOfSize:PdfRatio(34) weight:UIFontWeightRegular];
    self.pdfVipPriceLab.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.pdfVipPriceLab];
    [self.pdfVipPriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(60)));
        make.right.equalTo(@(-PdfRatio(60)));
        make.top.equalTo(@(PdfRatio(873) + PdfTopSafeHeight));
        make.height.equalTo(@(PdfRatio(147)));
    }];
    NSString * pdfVipPrice = [NSString stringWithFormat:@"订阅费用会在用户确认购买时从 iTunes 账户扣除，免费试用三天，可自动续订，续费￥298/年"];
    NSString * pdfVipPriceChange = [NSString stringWithFormat:@"续费￥0/年"];
    NSRange vipPriceRange = [pdfVipPrice rangeOfString:pdfVipPriceChange];
    NSMutableAttributedString *pdfVipMutPrice = [[NSMutableAttributedString alloc] initWithString:pdfVipPrice];
    [pdfVipMutPrice addAttribute:NSForegroundColorAttributeName value:PdfHex(@"#FFFFFF") range:NSMakeRange(0,pdfVipMutPrice.length)];
    [pdfVipMutPrice addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:PdfRatio(28) weight:UIFontWeightRegular] range:NSMakeRange(0,pdfVipMutPrice.length)];
    [pdfVipMutPrice addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:PdfRatio(32) weight:UIFontWeightBold] range:vipPriceRange];
    self.pdfVipPriceLab.attributedText = pdfVipMutPrice;
    
    self.pdfVipAlertLab = [[UILabel alloc] init];
    self.pdfVipAlertLab.numberOfLines = 0;
    self.pdfVipAlertLab.textColor = PdfHex(@"#16133E");
    self.pdfVipAlertLab.text = @"用户可在当前订阅结束 24 小时前关闭自动续订，否则将自动续订。自动续期订阅的 Apple ID，会在每个账单周期到期前24小时，自动在iTunes账户扣费并延长相应有效期。用户可以管理订阅。购买后可前往用户账户设置来关闭自动续订。";
    self.pdfVipAlertLab.font = [UIFont systemFontOfSize:PdfRatio(24) weight:UIFontWeightRegular];
    self.pdfVipAlertLab.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.pdfVipAlertLab];
    [self.pdfVipAlertLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(60)));
        make.right.equalTo(@(-PdfRatio(70)));
        make.top.equalTo(self.pdfVipPriceLab.mas_bottom).offset(PdfRatio(13));
        make.height.equalTo(@(PdfRatio(202)));
    }];
    
    UIButton * pdfVipGoBtn = [[UIButton alloc] init];
    pdfVipGoBtn.tag = 1000;
    [pdfVipGoBtn setBackgroundImage:PdfImageNamed(@"pdfVipGo") forState:UIControlStateNormal];
    [pdfVipGoBtn addTarget:self action:@selector(pdfVipGo) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pdfVipGoBtn];
    [pdfVipGoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.pdfVipAlertLab.mas_bottom).offset(PdfRatio(21));
        make.width.equalTo(@(PdfRatio(536)));
        make.height.equalTo(@(PdfRatio(82)));
    }];
    UIButton * pdfVipPriAgreementBtn = [[UIButton alloc] init];
    [pdfVipPriAgreementBtn addTarget:self action:@selector(pdfVipPriAgreement) forControlEvents:UIControlEventTouchUpInside];
    [pdfVipPriAgreementBtn setTitle:@"隐私协议" forState:UIControlStateNormal];
    [pdfVipPriAgreementBtn setTitleColor:PdfHex(@"#10241A") forState:UIControlStateNormal];
    pdfVipPriAgreementBtn.titleLabel.font = [UIFont systemFontOfSize:PdfRatio(24) weight:UIFontWeightRegular];
    [self.view addSubview:pdfVipPriAgreementBtn];
    [pdfVipPriAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.width.equalTo(@(PdfRatio(125)));
        make.height.equalTo(@(PdfRatio(40)));
        make.bottom.equalTo(@(-PdfRatio(127)));
    }];
    UIButton * pdfVipUserAgreementBtn = [[UIButton alloc] init];
    [pdfVipUserAgreementBtn addTarget:self action:@selector(vipUserAgreement) forControlEvents:UIControlEventTouchUpInside];
    [pdfVipUserAgreementBtn setTitle:@"用户协议" forState:UIControlStateNormal];
    [pdfVipUserAgreementBtn setTitleColor:PdfHex(@"#10241A") forState:UIControlStateNormal];
    pdfVipUserAgreementBtn.titleLabel.font = [UIFont systemFontOfSize:PdfRatio(24) weight:UIFontWeightRegular];
    [self.view addSubview:pdfVipUserAgreementBtn];
    [pdfVipUserAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(pdfVipPriAgreementBtn.mas_left);
        make.width.equalTo(@(PdfRatio(125)));
        make.height.equalTo(@(PdfRatio(40)));
        make.top.equalTo(pdfVipPriAgreementBtn);
    }];
    UIButton * pdfVipUserBuyBtn = [[UIButton alloc] init];
    pdfVipUserBuyBtn.tag = 1001;
    [pdfVipUserBuyBtn addTarget:self action:@selector(pdfVipUserBuy:) forControlEvents:UIControlEventTouchUpInside];
    [pdfVipUserBuyBtn setTitle:@"恢复购买" forState:UIControlStateNormal];
    [pdfVipUserBuyBtn setTitleColor:PdfHex(@"#10241A") forState:UIControlStateNormal];
    pdfVipUserBuyBtn.titleLabel.font = [UIFont systemFontOfSize:PdfRatio(24) weight:UIFontWeightRegular];
    [self.view addSubview:pdfVipUserBuyBtn];
    [pdfVipUserBuyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(pdfVipPriAgreementBtn.mas_right);
        make.width.equalTo(@(PdfRatio(125)));
        make.height.equalTo(@(PdfRatio(40)));
        make.top.equalTo(pdfVipPriAgreementBtn);
    }];
}
- (void)pdfVipBack{
    [self dismissViewControllerAnimated:true completion:^{
            
    }];
}
- (void)pdfVipGo{
    
}
- (void)pdfVipPriAgreement{
    
}
- (void)vipUserAgreement{
    
}
- (void)pdfVipUserBuy:(UIButton *)sender{
    
}
@end
